package com.azure.service;


import com.azure.entity.AAdmin;
import com.azure.mapper.report.AAdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by liuhuaibin on 2018/3/11.
 */
@Service
public class LoginRegisterService {

    @Autowired
    private AAdminMapper aAdminMapper;

    public boolean login(String username, String password){
        if(username == null || "".equals(username) || password == null || "".equals(password)){
            return false;
        }
        List<AAdmin> aAdmins = aAdminMapper.selectByUsernameAndPassword(username, password);
        if(aAdmins == null || aAdmins.size() == 0){
            return false;
        }else {
            return true;
        }
    }
    public boolean register(String username, String password){
        if(username == null || "".equals(username)){
            return false;
        }
        List<AAdmin> aAdmins = aAdminMapper.selectByUsername(username);
        if(aAdmins == null || aAdmins.size() == 0){
            aAdminMapper.insert(new AAdmin(username,password));
            return true;
        }else{
            return false;
        }
    }

}
